Greg's Basic UNIX crib sheet 1-10-2013
ls | Lists your files (Dir) | -l lists your files in 'long format' -a lists all files, including the ones whose filenames begin in a dot |
more <filename> | Shows the first part of a file | just as much as will fit on one screen. Just hit the space bar to see more or q to quit. |
cp <filename1> <filename2> | Copy | |
mv <filename1> <filename2> | Move or Rename | |
rm <filename> | Remove (Del) | |
cd <dirname> | Change directory | |
mkdir <dirname> | Make a new directory | |
pwd | Tells you where you currently are | |
pico <filename> | Text editor | |
chmod <options> <filename> | Change file attributes | +x add excutable, -w remove write |
chown <user> <file> | Change the owner | |
find <options> <filename> | Find files | -name "*anyname*" Special shell pattern matching characters (``['', ``]'', ``*'', and ``?'') may be used as part of pattern. These characters may be matched explicitly by escaping them with a backslash (``\''). |
gzip <filename> | Compresses files | |
date | Set or display the date | |
du | Disk usage | -h "human-readable" output, -d <x> depth of directorys, -c display a grand total eg. du -h -c -d 1 |
man <command> | Show command maunal | |
sudo tcpdump -vv not host 192.168.0.250 | network dump from ethernet port | |
dig @<dns_server_ip> <domain> | lookup a domin name using dns | e.g. dig @8.8.8.8 burnard.co.uk |
/usr/sbin/traceroute -n -w 2 -q 2 -m 30 8.8.8.8 | Traceroute | -n Print hop addresses numerically -m max_ttl -q x Set the number of probes per ttl -w Set the time (in seconds) to wait for a response |
lookupd -flushcache | Clear DNS cache | Clear DNS cache in OSX 10.4 and below |
dscacheutil -flushcache | Clear DNS cache | Clear DNS cache in OSX 10.5 and above |
netstat -rn | Show network routing | |
su | Enter Super User mode | |
resetpassword | To reset the OS X account password 10.7 and above | To reset the OS X account password if you do not have admin rights, boot in to recovery partition with Apple 'R' and then enter terminal and type 'resetpasword', afterwards type 'reboot'. |